<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var xhr;

    if(window.XMLHttpRequest) {
      xhr = new XMLHttpRequest();
    } else {
      xhr = new ActiveXObject('Microsoft.XMLHTTP')
    }

    xhr.outimeout = function () {
      xhr.abort()
      xhr = null;
    }

    xhr.onreadystatechange = function () {
      console.log(xhr)
      if(xhr.readyState === 4 && xhr.status === 200) {
        console.log('success')
      }
    }

    xhr.open('POST', 'https://www.baidu.com', true)
    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded')
    xhr.outimeout = 30000
    xhr.send('status=1&flag=2')
  </script>
</body>
</html>